#ifndef QIRRATTRIBUTESPROXY_H
#define QIRRATTRIBUTESPROXY_H

#include <QObject>
#include <irrlicht.h>

#include "QPropertyModel.h"

namespace QPE
{

//! \brief This class takes a set if Irrlicht attributes and
//!		displays them in the property browser
//!
//! If you are using the IAttributes-class from Irrlicht, this
//! proxy is the right thing to use. Just call setAttributes()
//! with a pointer to an IAttributes-obejct and
class QIrrAttributesProxy : public QPropertyModel
{
	Q_OBJECT
public:
	//! Constructor
	explicit QIrrAttributesProxy(QObject *parent = 0);

	//! Destructor
	virtual ~QIrrAttributesProxy();

	//! \brief Fills the property browser with the attributs provided.
	//!
	//! Do NOT delete attributes for they are being stored by
	//! this model.
	//!	In order to clear the model, use NULL as attribute or call
	//! clear().
	//! \param attributes The attributes you want QtPropertyExplorer to display. Set this to NULL to clear the model.
	void setAttributes(irr::io::IAttributes* attributes);

	//! Updates all the attributes and refills the property editor
	void updateAllProperties();

	//! Clears the model
	virtual void clear();

signals:
	//! This signal is being emitted, when an attribute gets changed
	void attributesChangedByEditor(irr::io::IAttributes* attributes);

public slots:
	//! Call this when an irrlicht attribute got changed
	void onAttributeChanged(const irr::core::stringc& name);

	//! This is being called when the user changes a property using the editor
	void onAttributeChangedByEditor(QProperty* property);

protected:
	//! Pointer to the irrlicht attrubutes
	irr::io::IAttributes* Attributes;

	//! Converts a QString into an irrlicht string
	static irr::core::stringc convertQStringToIrrString(const QString& str);

	//! Converts an irrlicht string into a QString
	static QString convertIrrStringToQString(const irr::core::stringc& str);


};


}

#endif // QIRRATTRIBUTESPROXY_H
